home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / Bowers Development / AppMaker 2.0b5 / Examples / ODF / AMSample / Sources / Part.cpp < prev    next >
Encoding:
Text File  |  1996-06-03  |  6.3 KB  |  261 lines  |  [TEXT/CWIE]

  1. //========================================================================================
  2. //
  3. //    File:                Part.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "AMSample.hpp"
  11.  
  12. #ifndef PART_H
  13. #include "Part.h"
  14. #endif
  15.  
  16. #ifndef CONTENT_H
  17. #include "Content.h"
  18. #endif
  19.  
  20. #ifndef BINDING_K
  21. #include "Binding.k"
  22. #endif
  23.  
  24. #ifndef FRAME_H
  25. #include "Frame.h"
  26. #endif
  27.  
  28. #ifndef SELECT_H
  29. #include "Select.h"
  30. #endif
  31.  
  32. // ----- Framework Layer -----
  33.  
  34. #ifndef FWUTIL_H
  35. #include "FWUtil.h"
  36. #endif
  37.  
  38. #ifndef FWITERS_H
  39. #include "FWIters.h"
  40. #endif
  41.  
  42. #ifndef FWPRESEN_H
  43. #include "FWPresen.h"
  44. #endif
  45.  
  46. // ----- OS Layer -----
  47.  
  48. #ifndef FWMENU_H
  49. #include "FWMenu.h"
  50. #endif
  51.  
  52. #ifndef FWCFMRES_H
  53. #include "FWCFMRes.h"
  54. #endif
  55.  
  56. #ifndef FWRESTYP_H
  57. #include "FWResTyp.h"
  58. #endif
  59.  
  60. #ifndef FWSUSINK_H
  61. #include "FWSUSink.h"
  62. #endif
  63.  
  64. #ifndef FWEVENT_H
  65. #include "FWEvent.h"
  66. #endif
  67.  
  68. #ifndef FWBARRAY_H
  69. #include "FWBArray.h"
  70. #endif
  71.  
  72. #ifndef FWABOUT_H
  73. #include "FWAbout.h"
  74. #endif
  75.  
  76. // ----- Foundation Includes -----
  77.  
  78. #ifndef FWFLOWIN_H
  79. #include "FWFloWin.h"        // FW_CFloatingWindow
  80. #endif
  81.  
  82. #ifndef FWSTREAM_H
  83. #include "FWStream.h"
  84. #endif
  85.  
  86. #ifndef FWSTRS_H
  87. #include "FWStrs.h"
  88. #endif
  89.  
  90. #ifndef FWSUSINK_H
  91. #include "FWSUSink.h"
  92. #endif
  93.  
  94. // ----- OpenDoc Includes -----
  95.  
  96. #ifndef SOM_Module_OpenDoc_StdProps_defined
  97. #include <StdProps.xh>
  98. #endif
  99.  
  100. #ifndef SOM_ODTranslation_xh
  101. #include <Translt.xh>
  102. #endif
  103.  
  104. #ifndef SOM_ODSession_xh
  105. #include <ODSessn.xh>
  106. #endif
  107.  
  108. //========================================================================================
  109. // Constants and Globals
  110. //========================================================================================
  111.  
  112. #define kMainPresentation    "BowersDev:Presentation:AMSample"
  113.  
  114. //========================================================================================
  115. //    Runtime info
  116. //========================================================================================
  117.  
  118. #ifdef FW_BUILD_MAC
  119. #pragma segment AMSample
  120. #endif
  121.  
  122. FW_DEFINE_AUTO(CAMSamplePart)
  123.  
  124. //========================================================================================
  125. //    CAMSamplePart class
  126. //========================================================================================
  127.  
  128. //----------------------------------------------------------------------------------------
  129. // CAMSamplePart constructor
  130. //----------------------------------------------------------------------------------------
  131.  
  132. CAMSamplePart::CAMSamplePart(ODPart* odPart) :
  133.     FW_CPart(odPart, FW_gInstance, kPartInfoID),
  134.     fPartContent(NULL),
  135.     fMainPresentation(NULL)
  136. {
  137. }
  138.  
  139. //----------------------------------------------------------------------------------------
  140. // CAMSamplePart destructor
  141. //----------------------------------------------------------------------------------------
  142.  
  143. CAMSamplePart::~CAMSamplePart()
  144. {
  145. }
  146.  
  147. //----------------------------------------------------------------------------------------
  148. // CAMSamplePart::Initialize
  149. //----------------------------------------------------------------------------------------
  150.  
  151. void CAMSamplePart::Initialize(Environment* ev)
  152. {
  153.     FW_CPart::Initialize(ev);
  154.  
  155.     // ----- Register Presentations
  156.     fMainPresentation = RegisterPresentation(ev, kMainPresentation, TRUE, 
  157.                                      FW_NEW(CAMSampleSelection, (ev, fPartContent)));
  158.  
  159.     // ----- Initialize my menu -----
  160.     GetMenuBar(ev)->InitializeFromResource(ev, kMenuBar);
  161. }
  162.  
  163. //----------------------------------------------------------------------------------------
  164. // CAMSamplePart::NewFrame
  165. //----------------------------------------------------------------------------------------
  166.  
  167. FW_CFrame* CAMSamplePart::NewFrame(Environment* ev,
  168.                                 ODFrame* odFrame,
  169.                                 FW_CPresentation* presentation,
  170.                                 FW_Boolean fromStorage)
  171. {
  172.     FW_UNUSED(fromStorage);
  173.     FW_CFrame* newFrame = NULL;
  174.  
  175.     if (presentation == fMainPresentation) {
  176.         newFrame = FW_NEW(CAMSampleFrame, (ev, odFrame, presentation, fPartContent));
  177.     }
  178.     return newFrame;
  179. }
  180.  
  181. //------------------------------------------------------------------------------
  182. // CAMSamplePart::NewPartContent
  183. //------------------------------------------------------------------------------
  184.  
  185. FW_CContent* CAMSamplePart::NewPartContent(Environment* ev)
  186. {
  187.     fPartContent = FW_NEW(CAMSampleContent, (ev, this));
  188.     return fPartContent;
  189. }
  190.  
  191. //----------------------------------------------------------------------------------------
  192. // CAMSamplePart::DoMenu
  193. //----------------------------------------------------------------------------------------
  194.  
  195. FW_Boolean CAMSamplePart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
  196. {
  197.     FW_Boolean menuHandled = TRUE;
  198.     ODCommandID id = theMenuEvent.GetCommandID(ev);
  199.  
  200.     switch (id)
  201.     {
  202.         case cStuffCommand:
  203.         case cMoreStuffCommand:
  204.         case cStillMoreCommand:
  205.             this->DoAMSampleCommand(ev, id);
  206.             menuHandled = TRUE;
  207.             break;
  208.  
  209.         case kODCommandAbout:
  210.             ::FW_About(ev, this, kAbout);
  211.             break;
  212.  
  213.         default:
  214.             menuHandled = FALSE;
  215.     }
  216.  
  217.     return menuHandled;
  218. }
  219.  
  220. //----------------------------------------------------------------------------------------
  221. // CAMSamplePart::DoAdjustMenus
  222. //----------------------------------------------------------------------------------------
  223.  
  224. FW_Boolean CAMSamplePart::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, 
  225.                                      FW_Boolean hasMenuFocus,
  226.                                      FW_Boolean isRoot)
  227. {
  228.     if (hasMenuFocus)
  229.     {
  230.         menuBar->EnableCommand(ev, cStuffCommand, TRUE);
  231.         menuBar->EnableCommand(ev, cMoreStuffCommand, TRUE);
  232.         menuBar->EnableCommand(ev, cStillMoreCommand, TRUE);
  233.     }
  234.  
  235.     return FALSE;
  236. }
  237.  
  238. //----------------------------------------------------------------------------------------
  239. // CAMSamplePart::DoAMSampleCommand
  240. //----------------------------------------------------------------------------------------
  241.  
  242. void CAMSamplePart::DoAMSampleCommand(Environment* ev, ODCommandID id)
  243. {
  244. }
  245.  
  246. //----------------------------------------------------------------------------------------
  247. // CAMSamplePart::PartChanged
  248. //----------------------------------------------------------------------------------------
  249.  
  250. void CAMSamplePart::PartChanged(Environment* ev)
  251. {
  252.     // Mark the document's draft as changed so it can be saved
  253.     this->Changed(ev);
  254.  
  255.     // Mark the display frame as changed, so that containing parts can update links
  256.     fMainPresentation->ContentUpdated(ev);
  257.  
  258.     // Force all display frames to be redrawn
  259.     fMainPresentation->Invalidate(ev);
  260. }
  261.